<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
$title='收信箱';
if($_GET['ref']=='1')$title='发信箱';
$tmp = User::getUserById($rs->from_uid);
// $black=Black::model()->findByAttributes();
?>
<div class="title">
	<h3><?php echo $title; ?>--信件查看</h3>
	<ul>
		<li <?php if($_GET['ref']==2):?>class="current"<?php endif;?>><?php echo CHtml::link('收件箱', array('pm/inbox'),array('title'=>'收件箱'))?></li>
		<li <?php if($_GET['ref']==1):?>class="current"<?php endif;?>><?php echo CHtml::link('发件箱', array('pm/outbox'),array('title'=>'发件箱'))?></li>
	</ul>
</div>
<div class="main_content">
	<div class="view">
		<div class="view_title">
			<div class="left">
				<p class="from"><strong>来自：</strong><?php echo $tmp->nickname,' ',User::getSex($tmp->sex),',',Utils::getAge($tmp->birth);?> 岁，<?php echo Area::getName($tmp->city_id);?></p>
				<p><strong>时间：</strong><?php echo $rs->ctime;?></p>
				<p><strong>话题：</strong><?php echo nl2br(CHtml::encode($rs->subject));?></p>
			</div>
			<div class="right"><a href="?r=space&id=<?php echo $tmp->id;?>"><img src="<?php echo Utils::getAvatar($tmp->avatar);?>" width="56" height="56" alt="<?php echo $tmp->nickname;?>"/></a></div>
		</div>
		<div class="view_content">
			<?php echo nl2br(CHtml::encode($rs->content));?>
		</div>
		<?php if($_GET['ref']==2):?>
		<div class="view_operation"> <a href="?r=pm/new&tid=<?php echo $tmp->id;?>"><span class="reply">回复</span></a><span class="delete">删除</span><span tag="<?php echo $tmp->id;?>" class="complaint">投诉举报</span> </div>
	<?php endif;?>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	<?php if($_GET['ref']==1):?>
	$('#outbox').addClass('hover');
	<?else:?>
	$('#inbox').addClass('hover');
	<?php endif;?>
	$('.delete').click(function(){
		if(confirm('确认删除此消息？')){
			var data = {mids:<?php echo $rs->id;?>};
			$.post('?r=pm/delete',{type:'inbox',mids:data},function(msg){
				msg = $.parseJSON(msg);
				if(msg.status=='0'){
					 window.location.href="?r=pm/inbox";

				}else{
					alert(msg.desc);

				}
				$("input.allcheck").attr("checked",false);
				$(".mask").remove();
				$(".dialog").remove();
			})
		}
	})
	$('.complaint').click(function(){
		if(confirm('投诉举报后用户同时会被加入您的黑名单，确定？')){
			$.post('?r=home/set',{act:'black',id:$(this).attr('tag')},function(data){
				data = $.parseJSON(data);
				if(data.status!='0'){
                              alert(data.desc);
                }else{
                	 window.location.href="?r=pm/inbox";
                }
			})
		}
	})
})

</script>